package com.wt.controller;

import com.wt.pojo.User;
import com.wt.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/test")
@RestController
public class ConsumerController {

    @Resource
    private UserService userService;

    @PostMapping
    public String add(User u){
        System.out.println("222user="+u);
        String add = userService.add(u);
        return add;
    }

    @DeleteMapping("/{id}")
    public String delete(@PathVariable("id") Integer id){
        String delete = userService.delete(id);
        return delete;
    }

    @PutMapping
    public String update(User u){
        System.out.println("222user-upd="+u);
        String update = userService.update(u);
        return update;
    }

    @GetMapping
    public String getUser(String name,Integer age){
        System.out.println("222user-getuser="+name+"  age="+age);
        String s = userService.GetUsers(name, age);
        return s;
    }

    @GetMapping("list")
    public List<User> list(User u){
        System.out.println("222user-getlist="+u);
        List<User> list = userService.list(u);
        return list;
    }
}
